package ly.gupao.edu.designPattern.prototype;

import java.io.Serializable;


/**
 * 创建一个邮件的实体类，类中包括邮件的名字、账号以及邮件模板对象的属性，但是这个实体类需要实例化clonable的接口
 */
public class Mail implements Cloneable, Serializable{

    private String name;

    private String number;

    private MailTemplate mailTemplate;

    public Mail(String name, String number, MailTemplate mailTemplate) {
        this.name = name;
        this.number = number;
        this.mailTemplate = mailTemplate;
    }

    @Override
    public String toString() {
        return "Mail{" +
                "name='" + name + '\'' +
                ", number='" + number + '\'' +
                ", mailTemplate=" + mailTemplate +
                '}';
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public void setMailTemplate(MailTemplate mailTemplate) {
        this.mailTemplate = mailTemplate;
    }

    public String getName() {
        return name;
    }

    public String getNumber() {
        return number;
    }

    public MailTemplate getMailTemplate() {
        return mailTemplate;
    }

    @Override
    public Object clone() throws CloneNotSupportedException {
        Mail mail = (Mail) super.clone();
//        mail.setMailTemplate((MailTemplate) this.mailTemplate.clone());
        return mail;
    }
}
